package system.service.impl;


import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import system.service.IAdminService;

import common.dao.AdminDAO;
import common.pojo.SysAdmin;


/**
 * @author jyl
 * @version 创建时间：2012-5-20 下午01:23:20
 * 类说明
 */
@Scope("prototype")
@Service
public class AdminServiceImpl implements IAdminService {
	@Resource
	private AdminDAO adminDAO;

	public SysAdmin getByName(String name) {
		return adminDAO.findByName(name);
	}

	public SysAdmin findById(int id) {
		return adminDAO.findById(id);
	}

	public boolean update(SysAdmin admin) {
		adminDAO.update(admin);
		return true;
	}

	public boolean updateAdmin(SysAdmin admin) {
		adminDAO.updateAdmin(admin);
		return true;
	}

	public boolean updatepwd(SysAdmin admin) {
		adminDAO.updatepwd(admin);
		return true;
	}

	public List<SysAdmin> find(int start, int limit) {
		return adminDAO.findList(start,limit);
	}

	public int getCount() {		
		return adminDAO.getCount();
	}

	public boolean saveAdmin(SysAdmin admin) {
		adminDAO.saveAdmin(admin);
		return true;
	}

	public boolean delete(String ids) {
		String[] id = StringUtils.split(ids, ",");
		for(int i=0;i<id.length;i++){
			adminDAO.delete(Integer.valueOf(id[i]));
		}
		return true;
	}
}
